<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/include.inc.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/views/layout/miiteen/base.ref.jsp" %>
</head>
<body>
<div class="mainpage edit">
    <!--顶部菜单-->
    <div class="page-topmenu">
        <shiro:hasPermission name="securityAccount:edit">
            <div class="btn-panel">
                <el-button type="primary" size="small" icon="el-icon-check" @click="save">保存</el-button>
            </div>
        </shiro:hasPermission>
        <div class="btn-panel">
            <el-button size="small" icon="el-icon-back" @click="back">返回</el-button>
        </div>
    </div>
    <!--编辑表单-->
    <el-form :ref="formid" :model="form" :rules="rules" size="small" :label-width="labelwidth"
             :label-position="labelposition"
             class="one-col" :validate-on-rule-change="false">
        <!--视业务进行更改-begin-->
        <el-form-item label="账号" prop="account" v-if="form.id<1">
            <el-input v-model="form.account" placeholder="账号"></el-input>
        </el-form-item>
        <el-form-item label="账号" v-if="form.id>0">
            {{form.account}}
        </el-form-item>
        <el-form-item label="密码" prop="pwd" v-if="form.id<1">
            <el-input placeholder="密码" v-model="form.pwd" show-password></el-input>
        </el-form-item>
        <el-form-item label="排序" prop="showOrder">
            <el-input v-model.number="form.showOrder" placeholder="排序"></el-input>
        </el-form-item>
        <el-form-item label="状态" prop="isValid">
            <el-radio-group v-model="form.isValid">
                <el-radio :label="1">有效</el-radio>
                <el-radio :label="2">无效</el-radio>
            </el-radio-group>
        </el-form-item>
        <el-form-item label="角色" prop="roleIds">
            <el-input v-model="form.roleNames" placeholder="角色" @focus="selectRole"></el-input>
        </el-form-item>
        <el-form-item label="账号类型" prop="accountTypes">
            <el-checkbox-group v-model="form.accountTypes">
                <el-checkbox v-for="accountType in accountTypes" :label="accountType.id"
                             :key="accountType.id">
                    {{accountType.name}}
                </el-checkbox>
            </el-checkbox-group>
        </el-form-item>
        <!--视业务进行更改-end-->
    </el-form>
</div>
<script>
    //初始化数据，必须放置在列表页面封装部分前
    function initVueOption(obj) {
        //设置控制器
        obj.data.controller = "${ctx}/security/securityaccount";
        //设置表单数据
        obj.data.form = ${securityAccount};
        //设置校验规则，没有则删掉
        obj.data.rules = {
            account: [
                {required: true, message: '请输入账号', trigger: 'blur'}
            ],
            pwd: [
                {required: true, message: '请输入密码', trigger: 'blur'}
            ],
            showOrder: [
                {required: true, message: '请输入序号', trigger: 'blur'},
                {type: "number", message: '只能输入数字'}
            ],
            isValid: [
                {required: true, type: "number", min: 1, message: '请选择状态', trigger: 'blur'}
            ],
            roleIds: [
                {required: true, message: '请选择角色', trigger: 'blur'}
            ],
            accountTypes: [
                {required: true, message: '请选择账号类型', trigger: 'blur'}
            ]
        }

        //账号类型
        obj.data.accountTypes =${accountTypes};

        //选择角色
        obj.methods.selectRole = function () {
            miiteen.customsearch.open("sysRole", function (result) {
                var role = result[0];
                Page.form.roleIds = role.result1;
                Page.form.roleNames = role.result2;
            }, {
                title: "",
                type: "list",
                multiple: false
            })
        }
    }
</script>
<!--编辑页面封装部分-->
<%@include file="/WEB-INF/views/layout/miiteen/page.edit.ref.jsp" %>
</body>
</html>

